package com.smart.opcda.mqtt;

import net.dreamlu.iot.mqtt.spring.server.MqttServerTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @author dengqiao
 * @date 2024/3/19 16:00
 */
@Component
public class MqttServerService {
    @Autowired
    private MqttServerTemplate server;

    public boolean publish(String topic,String body) {
        return server.publishAll(topic, body.getBytes(StandardCharsets.UTF_8));
    }
}
